<!DOCTYPE html>
<html>

<head>
	<title>我的资料</title>
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
	<script src="/js/jquery/jquery.min.js"></script>
	<link rel="stylesheet" href="/css/font/css/font-awesome.min.css" />
	<script src="/js/plugins/jrender/jrender.min.js"></script>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
	<link rel="stylesheet" href="/css/reset.css" />
	<link rel="stylesheet" href="/css/myProfiles.css" />
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
	<script src="/js/common.js"></script>
	<link rel="stylesheet" href="/css/modalbox.css">
    <script src="/js/plugins/jquery-form/jquery.form.js"></script>

	<script>
        //取出共享的数据
        var id = getParams().id;
        var userId = JSON.parse(sessionStorage.getItem("user")).id;
		$(function () {
            console.log(id);


            //将数据设置到数据中
			$.get('/users/' + id,function (data) {
                console.log(data);
                $('.info').renderValues(data);
                sessionStorage.setItem("stranger",JSON.stringify(data));

                // 模态框数据填充
                $('#friendId').val(id);
                $.get('/friends/crowds',{id:userId},function (data) {
                    console.log(data);
                    $('#infoForm').renderValues({list:data});
                });
            });





            //发送私信/添加好友/拉入群聊
            $('.sendMassageBtn').click(function () {
                var message = $('#message').val() + "";
                console.log(message);
                var type = $(this).data('type');
                $.post('/messages',{'user.id':userId,'target.id':id,'content.content': message,type:type},function (data) {
                    console.log(data);
                    if(data.success){
                        $(document).dialog({
                            style:"IOS",
                            titleShow: false,
                            autoClose: 2000,
                            content: '信息发送成功',
                        });
                    }else{
                        $(document).dialog({
                            style:"IOS",
                            titleShow: false,
                            autoClose: 2000,
                            content: data.msg,
                        });
                    }
                });
            });

        });

        function get_href(item) {
            item.attr('href',item.data('href') + id);
        }
       /* $(function () {
            //查询关注数
            $.get('/users',{id:id},function (data) {
                console.log(data);
                /!*$('.fans').renderValues({list:data});*!/
            })
        })*/

	</script>


</head>

<body>
	<div class="nav-search">
			<a href="/index.html">
				<span><i class="fa fa-angle-left fa-2x" ></i></span>
			</a>
	</div>
	<hr/>
<div class="container">
	<div class="row info">
		<div class="col-2" style="margin-right: 25px;">
			<img  class="rounded-circle" render-src="headImgUrl">
		</div>
		<div class="col-8">
			<h5 render-html="nickName"></h5>
			<ul class="list-inline">
				<li class="list-inline-item"><small>常住地</small></li>
				<li class="list-inline-item" render-html="place"><small ></small></li>
				<!--<div class="fans" >
					<li class="list-inline-item"><small>关注<span >0</span></small></li>
				</div>-->
			</ul>
		</div>
	</div>



</div>

<hr />

<div class="row link-box">
	<div class="col">
		<!--他的游记-->
		<a data-href="/friend/travels.html?id=" id="travels">
		<li class="list-inline-item"><i class="fa fa-book fa-2x"></i></li>
		<li class="list-inline-item">
		<h7>他的游记</h7>
		<small><span>每日都有新内容</span></small></li>
		</a>

	</div>
	<div class="col">
		<!--他的个人资料-->
		<ul class="list-inline">
			<a data-href="/friend/info.html?id=" id="info">
			<li class="list-inline-item"> <i class="fa fa-user fa-fw fa-2x"></i> </li>
			<li class="list-inline-item">
			<h7>他的信息</h7>
			<small>查看详细信息</small></li>
			</a>
		</ul>
	</div>
	<script>
        get_href($('#travels'));
        get_href($('#info'));
	</script>
</div>
<hr />
    <div class="container info">
            <label>发送信息:</label><b></b><textarea class="form-control" rows="5" id="message"></textarea>
    </div>
	<!--个人资料的跳转页面-->
	<div class="d-flex setting" >
		<div class="p-2 flex-fill" style="text-align: center">
			<a href="javascript:;">
				<button class="btn sendMassageCrowdBtn" data-type="4">
					邀请成为群成员</button>
			</a>
		</div>
		<div class="p-2 flex-fill" style="text-align: center">
			<a href="javascript:;"><button class="btn sendMassageBtn" data-type="3">加为好友</button>
			</a></div>
        <div class="p-2 flex-fill" style="text-align: center">
            <a href="javascript:;"><button class="btn sendMassageBtn" data-type="1">发送私信</button>
            </a>
        </div>
	</div>


<!--<ul class="mainmenu">
	<li><a href="#" ><b><i class="fa fa-star fa-2x"></i></b><span>我的收藏</span></a></li>
	<li><a href="#" ><b><i class="fa fa-commenting-o fa-2x"></i></b><span>我的评论</span></a></li>

	<li><a href="#" ><b><i class="fa fa-list-ul fa-2x"></i></b><span>我的心愿单</span></a></li>
	<li><a href="#" ><b><i class="fa fa-bullhorn fa-2x"></i></b><span>我的消息</span></a></li>
	<li><a href="#" ><b><i class="fa fa-file-text fa-2x"></i></b><span>我的订单</span></a></li>
	<li><a href="#" ><b><i class="fa fa-briefcase fa-2x"></i></b><span>我的钱包</span></a></li>
</ul>-->


	<!--遮罩层-->
	<div id="edit_mask" class="none"></div>
	<!--邀请进群-->
	<div class="none edit_popup group">
		<div class="title">
			<div class="container info">
				<form id="infoForm" method="post" action="/messages" >
					<!--{'user.id':userId,'target.id':id,'content.content': message,type:type}-->
					<input type="hidden" name="target.id" id="friendId">
					<label>组名</label><select class="form-control" name="user.id" id="crowdId" render-loop="list">
						<option render-value="list.id" render-html="list.name"></option>
					</select>
				</form>
                <button class="btn btn-primary inviteCrowd">确认</button>
            </div>
		</div>
	</div>

	<script>
        $(function () {



            // 关闭
            function bindEvents() {
                $('.sendMassageCrowdBtn').on('click', edit);
                $('.btn_close').on('click', close_edit);
                $('.inviteCrowd').on('click',function () {
                    console.log($('#message').val());
                    $('#infoForm').ajaxSubmit({
						beforeSubmit:function (params, form, options) {
							params.push({name:"type",value:"4"});
							params.push({name:'content.content',value:$('#message').val()})
                        },
						success:function (data) {
							if(data.success){
								window.location.reload();
							}
                    	}
                	});
                });
            }

            bindEvents();

            function edit() {
                var left = ($(document).width() - parseInt($('.edit_popup').css('width'))) / 2;
                $('.group').css('left', left + 'px');
                $('.group').removeClass('none');
                $('#edit_mask').removeClass('none');
            };
            edit();

            function close_edit() {
                $('.edit_popup').addClass('none');
                $('#edit_mask').addClass('none');
            };
            close_edit();
            // 点击空白处 关闭  点击变比按钮也可以关闭
            $('#edit_mask').on('click', close_edit);
        });
	</script>
</body>

</html>